home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig04_08.jar
/
Ch04
/
Fig04_08
/
Fig04_08.cpp
Wrap
C/C++ Source or Header
|
1997-10-13
|
426b
|
20 lines
// Fig. 4.8: fig04_08.cppf
// Compute the sum of the elements of the array
#include <iostream.h>
int main()
{
const int arraySize = 12;
int a[ arraySize ] = { 1, 3, 5, 4, 7, 2, 99,
16, 45, 67, 89, 45 };
int total = 0;
for ( int i = 0; i < arraySize ; i++ )
total += a[ i ];
cout << "Total of array element values is " << total << endl;
return 0;
}